<?php
include('../../config.php');
/**
 * Created by PhpStorm.
 * User: 明哲
 * Date: 2016/4/27
 * Time: 13:50
 */
$id=$_GET['id'];
$ck=$_GET['ckVal'];
$pipeType=$_GET['pipeType'];
$benefit=$_GET['benefit'];
$benefit_rate=$_GET['benefitRate'];
$result=$mysql->query("select `status` from `product_data` where id = '{$id}' limit 1");
if($result[0]['status']==0){
    if($pipeType == 1){
        $rows=$mysql->query("update `product_data` set `status`=1 where id = '{$id}'");
    }else if($pipeType == 0){
        $rows=$mysql->query("update `product_data` set `status`=1,`benefit`='{$benefit}',`benefit_rate`='{$benefit_rate}',`active_user_ck`='{$ck}' where id = '{$id}'");

    }
    echo 1;
}else{
    if($pipeType == 1) {
        $rows = $mysql->query("update `product_data` set `status`=0 where id = '{$id}'");
    }else if($pipeType == 0){
        $rows = $mysql->query("update `product_data` set `status`=0,`benefit`=0,`benefit_rate`=0,`active_user_ck`=-1 where id = '{$id}'");

    }
        echo 1;
}
